package cn.edu.gxnu.dsa.lab;

import java.util.Scanner;

import cn.edu.gxnu.dsa.stack.LinkStack;
import cn.edu.gxnu.dsa.stack.SqStack;

public class CapReverse {
	SqStack squeceStack;
	LinkStack linkStack;

	public CapReverse() {
		squeceStack = new SqStack(200);
		linkStack = new LinkStack();
	}

	public void startSeqStack() {
		Scanner sc = new Scanner(System.in);
		String stringLine = null;
		System.out.println("Please input a sentence:");
		stringLine = sc.nextLine();
		for (int i = 0; i < stringLine.length(); i++) {
			try {
				squeceStack.push(Character.toUpperCase(stringLine.charAt(i)));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		while (!squeceStack.isEmpty()) {
			try {
				System.out.print(squeceStack.pop());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		System.out.println("");
	}

	public void startLinkStack() {
		Scanner sc = new Scanner(System.in);
		String stringLine = null;
		System.out.println("Please input a sentence:");
		stringLine = sc.nextLine();
		for (int i = 0; i < stringLine.length(); i++) {
			try {
				linkStack.push(Character.toUpperCase(stringLine.charAt(i)));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		while (!linkStack.isEmpty()) {
			try {
				System.out.print(linkStack.pop());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		System.out.println("");
	}

}
